package cn.neusoft.service.impl;

import cn.neusoft.domain.CargoBuyBill;
import cn.neusoft.mapper.BuyBillMapper;
import cn.neusoft.service.BuyBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BuyBillImp implements BuyBillService {
    @Autowired
    private BuyBillMapper buyBillMapper;


    @Override
    public List<CargoBuyBill> queryAllBuyBill() {
        return buyBillMapper.getAll();
    }
    @Override
    public int changeBuyBill(CargoBuyBill cargoBuyBill) {
        int ans = 0;

        if(cargoBuyBill != null){
            ans = buyBillMapper.update(cargoBuyBill);
        }

        return ans;
    }

    @Override
    public int deleteBuyBill(int billID) {
        int ans = 0;

        ans = buyBillMapper.deleteByID(billID);

        return ans;
    }
    @Override
    public int generateBuyBill(CargoBuyBill cargoBuyBill) {
        int ans = 0;

        if(cargoBuyBill != null){
            ans = buyBillMapper.insert(cargoBuyBill);
        }

        return ans;
    }

    @Override
    public CargoBuyBill getBuyBillByID(int id) {
        return buyBillMapper.findByID(id);
    }
}
